package com.shi.yibanjia.controller;

import com.shi.yibanjia.annotation.RateLimitRule;
import com.shi.yibanjia.annotation.RateLimiter;
import com.shi.yibanjia.common.Result;
import com.shi.yibanjia.enums.LimitType;
import com.shi.yibanjia.service.CarTypeService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/app/carType")
public class CarTypeController {

    @Resource
    private CarTypeService carTypeService;


    @RateLimiter(rules = @RateLimitRule(time = 60, count = 30), type = LimitType.IP)
    @Cacheable(value = "yibanjia:car", key = "'list'")
    @GetMapping
    public Result list() {
        return Result.ok(carTypeService.list());
    }

}
